/** 
    @file vector.hpp
    @brief Vector and point classes
*/
#ifndef PM3_VECTOR_H
#define PM3_VECTOR_H

#include <OgreVector3.h>

namespace pm3 {

/** @class VEC2
    @brief 2-dimensional vector class */
template <class T>
class VEC2 {
	public:
		VEC2 (T X = 0, T Y = 0);

        //! Vector coordinates
		T x, y;

		T& operator[] (const int &i_id);

		VEC2<T>& operator= (const VEC2 <T> &v);

		bool operator== (const VEC2 <T> &v) const;
		bool operator!= (const VEC2 <T> &v) const;

		VEC2<T> operator+ (const VEC2 <T> &v) const;

		VEC2<T> operator- (void) const;

		VEC2<T> operator- (const VEC2 <T> &v) const;

		VEC2<T> operator* (const T &t) const;
		T operator* (const VEC2 <T> &v) const;

		VEC2<T> operator/ (const T &t) const;

		VEC2<T>& operator+= (const VEC2 <T> &v);
		VEC2<T>& operator-= (const VEC2 <T> &v);
		VEC2<T>& operator*= (const T &t);
		VEC2<T>& operator/= (const T &t);
};

extern template class VEC2<int>;
extern template class VEC2<float>;

typedef VEC2<int>		VEC2I;
typedef VEC2<float>		VEC2F;

/** @class GRID_POINT
    @brief A gridpoint class */
class GRID_POINT {
    public:
        GRID_POINT();
        GRID_POINT( int i_layer, int i_x, int i_y );
        GRID_POINT( int i_layer, VEC2I v );
        GRID_POINT( const Ogre::Vector3 &r_v );

        //! ID of the layer that the grid point is on
        int m_layer;
        //! Point on the layer
        VEC2I m_point;

		GRID_POINT& operator= (const GRID_POINT &p);
        GRID_POINT& operator= (const Ogre::Vector3 &v);

		bool operator== (const GRID_POINT &p) const;
		bool operator!= (const GRID_POINT &p) const;

		GRID_POINT operator+ (const GRID_POINT &p) const;
		GRID_POINT operator- (void) const;
		GRID_POINT operator- (const GRID_POINT &p) const;
		GRID_POINT operator* (float f) const;
		GRID_POINT operator/ (float f) const;

		GRID_POINT& operator+= (const GRID_POINT &p);
		GRID_POINT& operator-= (const GRID_POINT &p);
		GRID_POINT& operator*= (float f);
		GRID_POINT& operator/= (float f);

        Ogre::Vector3 to_vec() const;
};

}

#endif // PM3_VECTOR_H

